package com.taopao.rxjavaretrofitcutmvp.ui.activity.utils;

import android.Manifest;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.taopao.rxjavaretrofitcutmvp.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PermissionActivity extends AppCompatActivity  {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_permission);
        ButterKnife.bind(this);

    }

    @OnClick(R.id.btn_camera) void onClick() {
//        Toast.makeText(PermissionActivity.this, "ass", Toast.LENGTH_SHORT).show();
//        EasyPermissions.requestPermissions(
//                new PermissionRequest
//                        .Builder(this, 0, Manifest.permission.READ_EXTERNAL_STORAGE)
//                        .setRationale("提示")
//                        .setNegativeButtonText("")
//                        .build()
//
//        );

//        EasyPermissions.requestPermissions(this, "申请权限",
//                0, Manifest.permission.CAMERA);

    }


//    @Override
//    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
//        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
//
//        // Forward results to EasyPermissions
//        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
//    }
//
//    @Override
//    public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
//
//    }
//
//    @Override
//    public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
//        //处理权限名字字符串
//        StringBuffer sb = new StringBuffer();
//        for (String str : perms){
//            sb.append(str);
//            sb.append("\n");
//        }
//        if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
//            new AppSettingsDialog
//                    .Builder(this)
//                    .setRationale("此功能需要" + sb + "权限，否则无法正常使用，是否打开设置")
//                    .setPositiveButton("好")
//                    .setNegativeButton("不行")
//                    .build()
//                    .show();
//        }
//    }
}
